Skip to content

fix: retry project detection when agent output has no JSON - #1305

Merged
gewenyu99 merged 5 commits into
mainfrom
codex/detection-json-retry-20260922
Sep 22, 2026
Merged

gewenyu99 merged 5 commits into
mainfrom
codex/detection-json-retry-20260922

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Retry project detection once in a fresh Haiku session when the first scan finishes without usable JSON or times out. Keep [ABORT] as a valid empty scan and preserve the existing error path for other agent failures.

The first SDK run has a 60-second limit; the retry has a separate 90-second limit. Each deadline aborts its SDK query. The wizard waits for the retry result instead of discarding it at the old 60-second caller deadline.

Flow

sequenceDiagram
  participant caller as Wizard caller
  participant detect as Project detector
  participant agent as Haiku agent runner
  participant parse as JSON parser
  caller->>detect: Scan repository
  detect->>agent: Fresh session, 60-second limit
  agent-->>detect: Transcript, result, or timeout
  detect->>parse: Combined output when run completes
  parse-->>detect: Report or no JSON
  alt Valid project JSON
    parse-->>detect: Report
    detect-->>caller: Select recommended project
  else ABORT marker
    detect-->>caller: Empty report
  else Timeout or no JSON
    detect-->>caller: Retry progress
    detect->>agent: Fresh session, 90-second limit
    agent-->>detect: Retry transcript, result, or timeout
    detect->>parse: Combined retry output when run completes
    parse-->>detect: Report or no JSON
    alt Valid project JSON
      detect-->>caller: Select recommended project
    else ABORT marker
      detect-->>caller: Empty report
    else No JSON or retry timeout
      detect-->>caller: Error or timeout; keep install directory
    end
  end
Loading

Verification

  • Detection and project selection: 19 tests passed.
  • Agent runner: 36 tests passed, including aborting an unfinished SDK query at its configured deadline.
  • MCP result utilities: 31 tests passed. Removed a duplicate scrubHomePaths export that blocked the build.
  • Lint (Prettier and ESLint) and git diff --check: passed.
  • Typecheck and full build, including postbuild smoke checks: passed.

@gewenyu99
gewenyu99 requested a review from a team as a code owner September 22, 2026 20:19
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@gewenyu99 gewenyu99 changed the title Retry project detection when agent output has no JSON fix: retry project detection when agent output has no JSON Sep 22, 2026
@gewenyu99
gewenyu99 merged commit 001edb6 into main Sep 22, 2026
20 checks passed
@gewenyu99
gewenyu99 deleted the codex/detection-json-retry-20260922 branch September 22, 2026 21:48
gewenyu99 added a commit that referenced this pull request Sep 23, 2026
Brings in the eight main fixes since beccc79 (#1275, #1280, #1284, #1294,
#1295, #1301, #1302, #1305). One conflict: agentic detection keeps main's
two-attempt retry loop from #1305 and adds A1's progress emitter to the
agent it initializes.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
gewenyu99 added a commit that referenced this pull request Sep 23, 2026
Brings the final Release A into B1: main through #1305, the per-request
ask signal, host-owned terminal analytics with the flush guard, and A3's
explicit failure status, fatal-path funnel events and linear run
cancellation.

Four conflicts, each resolved to A3's content at B1's program paths:
- the agent README paragraph that names the adapter;
- the import blocks of the adapter test and the project-scope test;
- #1305's new detection retry test, which lands in the renamed
  src/programs/detection/__tests__ and imports @programs/detection/agentic.

#1305's timeout entry lands in the renamed src/agent/error-map.ts.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
gewenyu99 added a commit that referenced this pull request Sep 23, 2026
…book

- Two agent entry comments said the bindings leave in B1. B1 deferred
  PROGRAM_BINDINGS to B2, so they say B2.
- The shared README said claude-settings.ts and errors/agent-map.ts import
  agent leaf modules. Neither does any more. The one agent import left in
  shared is the type-only InstallSkillResult in errors/skill-map.ts.
- The agentic detection runbook cited the removed
  AGENTIC_DETECTION_TIMEOUT_MS. Since #1305 the scan gets two attempts, 60s
  then 90s.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
gewenyu99 added a commit that referenced this pull request Sep 23, 2026
Brings the final Release A, through the new B1, into the callable program
host. B2's structure stays; A's agent contract holds throughout:
- asks and task notices take { signal }, and cancelAsk, cancelTaskNotice
  and cancelQuestion are gone;
- the linear sequence owns a run controller;
- the orchestrator's fatal path reports blocked tasks;
- the agent never sends terminal analytics.

The adapter calls wizardAbort with an explicit status: 'cancelled' only when
the host cancelled, 'error' otherwise. After a non-composed success it sends
'success' behind the flush guard.

main's fixes land where B2 moved the code:
- #1284's warehouse seed cap goes into posthog-integration/run.ts;
- #1280's scan step goes into B2's downloadSkill;
- #1305's two detection attempts share one inference-auth provider;
- the #1305 timer and B2's host-abort check sit side by side in
  agent-interface.

B2's skill-cleanup test now expects an agent [ABORT] to end as failed, and
its host-abort test checks that an unmarked user skill survives.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
gewenyu99 added a commit that referenced this pull request Sep 23, 2026
Brings the final Release A, through B1 and B2, into B3.

What landed in the renamed adapter, src/lib/runners/run-program-agent.ts
(git followed the rename):
- B2's runLegacyStep;
- the explicit wizardAbort status;
- 'success' sent behind the flush guard.

Detection keeps #1305's two attempts, with one inference-auth provider, plus
B3's host context. project-scope uses #1305's timeout handling through B3's
host. B3-11 is also in this merge: the dead AgenticDetectOptions.inferenceAuth
option is deleted, and a test checks that both attempts share the host's
progress and provider.

Seven conflicts, all resolved to both sides' intent.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
gewenyu99 added a commit that referenced this pull request Sep 24, 2026
Carries the final Release A branch, which now includes main's #1319,
#1235, #1305 and 2.77.0. Tests the merge added under src/lib/programs
move to src/programs with B1 import paths.

Generated-By: PostHog Desktop
Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants